<?php

/**
 * Created by XjHome.
 * User: xj
 * Date: 2015/5/20
 * Time: 23:43
 *php策略模式
 */
abstract class a
{

    abstract public function a1();

    public function a2()
    {
        echo '我是a2';
    }

}


class b1 extends a
{
    public function a1()
    {
        echo '我是b1';
    }

}

class b2 extends a
{
    public function a1()
    {
        echo '我是b2';

    }

}

class c extends a
{
    public  $s;
    public function __construct(a $class)
    {
        $this->s=$class;
    }

    public function a1()
    {
        $this->s->a1();
    }
}

    $b1=new b2;
    $c=new c($b1);
    $c->a1();